package com.rockcent.job.task;

import com.rockcent.mall.lib.domain.enumclass.ProductStatus;
import com.rockcent.service.MerchantProductSrv;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 产品过期下架
 * Created by zhangjh on 2016/11/23.
 */
@Component
public class MerchantProductTask {
    private final Logger log = LoggerFactory.getLogger(MerchantProductTask.class);

    @Autowired
    private MerchantProductSrv merchantProductSrvImpl;

    @Scheduled(cron = "0/58 * * * * *")
    public void soldout() {

        List<Long> ids = merchantProductSrvImpl.findAllSoldoutProductIds();
        if (ids != null) {

//            log.info("======================>过期的产品数有：" + ids.size());
            merchantProductSrvImpl.updateProductStatus(ProductStatus.SOLDOUT,ids);

        }

    }

}
